<?php
if (!defined('GLOBAL_START')) {
    require __DIR__ . '/../../vendor/autoload.php';
}

$configQueue = require __DIR__ . '/config.php';

if (!empty($configQueue['singleQueue'])) {
    foreach ($configQueue['singleQueue'] as $queueName => $workerNum) {
        $worker         = new YCore\QueueWorker();
        $worker->name   = $queueName . "QueueWorker";
        $worker->queues = [$queueName]; /** 任务名称 */
        $worker->count  = intval($workerNum) ?: 1;
    }
}

if (!empty($configQueue['multiQueue'])) {
    if (!is_numeric(end($configQueue['multiQueue']))) {
        $workerNum = 1;
    } else {
        $workerNum = array_pop($configQueue['multiQueue']);
    }
    $worker         = new YCore\QueueWorker();
    $worker->name   = "multiQueueWorker";
    $worker->queues = $configQueue['multiQueue']; /** 任务名称 */
    $worker->count  = intval($workerNum) ?: 1;
}

if (!defined('GLOBAL_START')) {
    Worker::runAll();
}
